package com.gs.douban.utils;

import java.util.HashMap;
import java.util.Map;

public class CookieProcesser {
	
	public static final synchronized Map<String, String> process(String cookie) {
		Map<String, String> map = new HashMap<String, String>();
		String[] cc = cookie.split(";");
		for (String cookieEntity : cc) {
			String[] c = cookieEntity.split("=");
			map.put(c[0].trim(), c[1].trim());
		}
		return map;
	}

	public static final synchronized String build(Map<String, String> map) {
		StringBuilder sb = new StringBuilder();
		for (String key : map.keySet()) {
			sb.append(key + "=" + map.get(key) + "; ");
		}
		return sb.toString();
	}
}
